package com.zj;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Iterator;

public class ReadExcel {

    public static void main(String[] args) {
        try {
            Workbook wb = null;
            File file = new File("/Users/piza/work/forty/营销/全国家具厂.xls");
            InputStream inputStream = new FileInputStream(file);
            wb = new HSSFWorkbook(inputStream);
            StringBuffer sb = new StringBuffer();

            Iterator<Sheet> sheetIterator = wb.sheetIterator();
            int total=0;
            while (sheetIterator.hasNext()) {
                Sheet sheet=sheetIterator.next();
                System.out.println(sheet.getSheetName()+":"+sheet.getLastRowNum());
                total+=sheet.getLastRowNum();
            }
            System.out.println("全国共："+total+"家");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
